package org.homly.admin.action.scheme;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.homly.admin.form.SchemeForm;
import org.homly.model.Scheme;
import org.homly.service.SchemeService;

public class SaveSchemeAction extends Action {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		SchemeForm schemeForm = (SchemeForm) form;
		Scheme scheme = new Scheme();

		BeanUtils.copyProperties(scheme, schemeForm);

		SchemeService.updateScheme(scheme);

		return new ActionForward(mapping.findForward("manager_scheme").getPath(), true);
	}

}
